<template>
  <div class="bg">
    <div class="title">短信营销</div>
    <!-- 副标题 -->
    <ul class="subheading">
      <li
        v-for="(item, index) in subheadingList"
        :key="index"
        :class="{ active: upClick == index }"
        @click="toPage(index)"
      >
        {{ item }}
      </li>
    </ul>

    <component :is="componentName" @toDetailPage="ToSecondPage" :messageId='recordId'></component>
  </div>
</template>

<script>
import messagePush from "../../components/message/messagePush.vue";
import messageTemplete from "../../components/message/messageTemplete.vue";
import messageRecord from "../../components/message/messageRecord.vue";
import messageRecordDetail from "../../components/message/messageRecordDetail.vue";

export default {
  components: {
    messagePush,
    messageTemplete,
    messageRecord,
    messageRecordDetail,
  },
  data() {
    return {
      upClick: 0,
      subheadingList: ["短信推送", "短信模板", "发送记录"],
      componentName: "messagePush",
      recordId:{}
    };
  },
  methods: {
    toPage(index) {
      sessionStorage.setItem("upClick", index);
      this.upClick = sessionStorage.getItem("upClick");
      if (index == 0) {
        this.componentName = "messagePush";
      } else if (index == 1) {
        this.componentName = "messageTemplete";
      } else if (index == 2) {
        this.componentName = "messageRecord";
      }
    },

    ToSecondPage(data) {
      this.recordId = data;
      // console.log("this.recordId.id",this.recordId.id);
      this.componentName = "messageRecordDetail";
    },
  },
};
</script>

<style lang="less" scoped>
.bg {
  // height: 92.5%;
  background: #ffffff;
  box-shadow: 0px 3px 20px 0px rgba(230, 230, 230, 0.8);
  border-radius: 10px;
  padding: 0.3rem 0.2rem;
  font-family: Microsoft YaHei;

  .title {
    font-size: 0.24rem;
    font-weight: bold;
    color: #333333;
    margin-left: 0.3rem;
    margin-bottom: 0.4rem;
    text-align: left;
  }

  // 副标题
  .subheading {
    list-style: none;
    display: flex;
    padding-left: 0;
    margin: 0;
    text-align: left;
    margin-left: 0.3rem;
    margin-bottom: 0.4rem;
    li {
      height: 0.3rem;
      font-size: 0.2rem;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #666666;
      line-height: 0.3rem;
      cursor: pointer;
      margin-right: 0.6rem;
    }
    .active {
      color: #f42551;
      font-weight: bold;
      border-bottom: 4px solid #f42551;
      border-radius: 1px;
    }
  }
}
</style>